package xyz.chaobei.thread.simple;

/**
 * @copyright (C), 2015-2020
 * @fileName: Main
 * @author: MRC
 * @date: 2021/1/25 22:59
 * @description:
 */
public class Main {

    public static void main(String[] args) {

        SimpleThread simple = new SimpleThread("simple");
        SimpleThread simple2 = new SimpleThread("desc");

        Thread thread = new Thread(simple);
        Thread thread2 = new Thread(simple2);
        // 获取当前线程名字
        System.out.println(Thread.currentThread().getName());
        System.out.println(thread.getThreadGroup().getName());
        System.out.println(thread.getName());
        System.out.println(thread2.getName());

        thread.start();
        thread2.start();

//        // 单一对象持有锁，多个线程抢占
//        CountObj obj = new CountObj();
//        CountThreadA a = new CountThreadA(obj);
//        CountThreadB b = new CountThreadB(obj);
//
//        a.start();
//        b.start();

//        // 死锁练习
//        DisLock disLock = new DisLock();
//
//        Thread a = new Thread(() -> {
//            for (int i = 0; i < 5; i++) {
//                disLock.add();
//            }
//        });
//        a.start();
//
//        Thread b = new Thread(() -> {
//            for (int i = 0; i < 5; i++) {
//                disLock.sub();
//            }
//        });
//        b.start();

        /**
         * DisLock add try catch lock...
         * DisLock sub try catch lockB...
         * DisLock add try catch lock success
         * DisLock add try catch lockB...
         * DisLock sub try catch lockB success
         * DisLock sub try catch lock...
         */
    }

}
